﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using eProject_SEM3_SecurityServices.ObjectClass;
using eProject_SEM3_SecurityServices.Bussiness;

namespace eProject_SEM3_SecurityServices
{
    public partial class EmployeeTask : System.Web.UI.Page
    {
        OEmployee employee;
        BEmployee employeeB;

        protected void Page_Load(object sender, EventArgs e)
        {
            employee = new OEmployee();
            employeeB = new BEmployee();

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            List<OEmployee> empList = new List<OEmployee>();
            empList = employeeB.GetEmployeeList();
            List<OEmployee> empList1 = new List<OEmployee>();

            switch (ddOption.SelectedValue)
            {
                case "1":
                    
                    for (int i = 0; i < empList.Count ;i++ )
                    {
                        if (empList[i].EmployeeID == Convert.ToInt32(tbSearchContent.Text))
                        {
                            empList1.Add(empList[i]);
                        }
                    }

                    break;
                case "2":

                    for (int i = 0; i < empList.Count; i++)
                    {
                        if (empList[i].EmployeeFullName.Equals(tbSearchContent.Text))
                        {
                            empList1.Add(empList[i]);
                        }
                    }
                    break;
                case "3":

                    for (int i = 0; i < empList.Count; i++)
                    {
                        if (empList[i].EmployeeID == Convert.ToInt32(tbSearchContent.Text))
                        {
                            empList1.Add(empList[i]);
                        }
                    }
                    break;
                case "4":

                    for (int i = 0; i < empList.Count; i++)
                    {
                        if (empList[i].EmployeeID == Convert.ToInt32(tbSearchContent.Text))
                        {
                            empList1.Add(empList[i]);
                        }
                    }
                    break;
                case "5":

                    for (int i = 0; i < empList.Count; i++)
                    {
                        if (empList[i].EmployeeID == Convert.ToInt32(tbSearchContent.Text))
                        {
                            empList1.Add(empList[i]);
                        }
                    }
                    break;
            }
            
            GridView1.DataSource = empList1;
            GridView1.DataBind();

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            tbSearchContent.Text = ((Label)GridView1.SelectedRow.FindControl("Label2")).Text;
        }
    }
}